﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Crypto;
using Plugin.Archives.Models;
using Plugin.Archives.Service;
using RsCode.Domain;

namespace Plugin.Archives.Controllers
{
	[Route("api/[controller]")]
	[ApiController]
	public class bmController : ControllerBase
	{
		BmAppService bmAppService;
		public bmController(BmAppService bmAppService)
        {
            this.bmAppService = bmAppService;
        }
        [Authorize]
		[HttpPost("edit")]
		public async Task<object> SaveAsync(BaomingEditDto dto)
		{
			return await bmAppService.SaveAsync(dto);
		}

		[Authorize]
		[HttpGet("info")]
		public async Task<object> GetAsync(long id)
		{
			return await bmAppService.GetAsync(id);
		}

		[Authorize]
		[HttpGet("list")]
		public async Task<object>PageAsync(int page,int pageSize)
		{
			return await bmAppService.PageInfoAsync(page,pageSize);
		}

		[Authorize("admin")]
		[HttpPost("search")]
		public async Task<object>SearchAsync(SearchDto dto)
		{
			return await bmAppService.SearchBmAsync(dto);
		}
		[Authorize("admin")]
		[HttpDelete("delete")]
		public async Task<object> DeleteAsync(int id)
		{
			return await bmAppService.DeleteAsync(id);
		}

		[Authorize("admin")]
		[HttpGet("stat")]
		public async Task<object> StatAsync()
		{
			//查询报名统计信息
			return await bmAppService.StatAsync();
		}

		//[Authorize("admin")]
		[HttpGet("rank")]
		public async Task<object> RankAsync()
		{
			//查询报名统计信息
			return await bmAppService.RankAsync();
		}
	}
}
